For a SU(N) Yang-Mills theory, we present variational calculations using gaussian wave functionals combined with an approximate projection on gauge invariant states. The projection amounts to correcting the energy of the gaussian states by substracting the spurious energy associated with gauge rotations. Based on this improved energy functional, we perform variational calculations of the interaction energy in the presence of external electric and magnetic fields. We verify that the ultraviolet behaviour of our approximation scheme is consistent, as it should, with that expected from perturbation theory. In particular, we recover in this variational framework the standard one-loop beta function, with a transparent interpretation of the screening and anti-screening contributions.